#include <iostream>
#include <queue>
using namespace std;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define pii pair<int, int>
const int N = 10;

int n, m;
int a[N][N];
int d[N][N];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
pii pre[N][N];

void bfs() {
  rep(i, 1, 5) rep(j, 1, 5) d[i][j] = 1e9;
  queue<pii> q;
  q.push(pii(1, 1));
  d[1][1] = 0;
  while (q.size()) {
    pii now = q.front();
    q.pop();
    int x = now.first, y = now.second;
    rep(i, 0, 3) {
      int xx = x + dx[i], yy = y + dy[i];
      if (xx < 1 || x > 5 || y < 1 || y > 5) continue;
      if (a[xx][yy] == 1) continue;
      if (d[xx][yy] > d[x][y] + 1) {
        pre[xx][yy] = now;
        d[xx][yy] = d[x][y] + 1;
        q.push(pii(xx, yy));
      }
    }
  }
}
void out(int x, int y) {
  if (x != 1 || y != 1) out(pre[x][y].first, pre[x][y].second);
  cout << '(' << x - 1 << ", " << y - 1 << ')' << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  rep(i, 1, 5) rep(j, 1, 5) cin >> a[i][j];
  bfs();
  out(5, 5);
  return 0;
}